"""
接口对象层

"""
import requests


class TpshopLoginApi(object):
    # 获取验证码cookies
    def get_cookies(self):
        resp = requests.get(url="http://127.0.0.1/index.php?m=Home&c=User&a=verify")
        my_cookies=resp.cookies

        return my_cookies

    # 定义登录,获取返回数据
    def tpshop_login(self,req_body,my_cookies):
        resp = requests.post(url="http://127.0.0.1/index.php?m=Home&c=User&a=do_login&t=0.7521243527261232",
                             data=req_body,
                             cookies=my_cookies)

        return resp



if __name__ == '__main__':
    # 创建实例化
    tpshop=TpshopLoginApi()
    # 调用
    co=tpshop.get_cookies()
    req_body={"username": "15176760665", "password": "123456", "verify_code": "8888"}
    res=tpshop.tpshop_login(req_body,co)
    print(res.json())